package com.jh3502.vivo.function.dialog;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.widget.EditText;

import com.jh3502.vivo.R;
import com.jh3502.vivo.base.BaseActivity;
import com.jh3502.vivo.base.BasePresenter;
import com.jh3502.vivo.view.SnackbarUtil;

import butterknife.BindView;
import butterknife.OnClick;
import cxy.com.validate.SimpleValidateResult;
import cxy.com.validate.Validate;
import cxy.com.validate.annotation.Index;
import cxy.com.validate.annotation.NotNull;

/**
 * @author harisucici
 * @version 2018/12/7 10:04
 * name
 * todo
 * @email harisucici@gmail.com
 */
public class DialogReason extends BaseActivity {
    @Index(0)
    @NotNull(msg = "请输入事由")
    @BindView(R.id.dialog_choice_reason)
    EditText dialogChoiceReason;

    @Override
    public BasePresenter initPresenter() {
        return null;
    }

    @Override
    protected int setViewId() {
        return R.layout.dialog_choose_reason;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void doOnDestroy() {

    }

    @Override
    protected void doOnResume() {

    }

    @Override
    protected void doOnSaveInstanceState(Bundle savedInstanceState) {

    }

    @Override
    public void responseError(int code, String msg) {

    }


    @OnClick(R.id.dialog_choice_cancel)
    public void onDialogChoiceCancelClicked() {
        onBackPressed();
    }

    @OnClick(R.id.dialog_choice_submit)
    public void onDialogChoiceSubmitClicked() {


        Validate.check(this, new SimpleValidateResult() {
            @Override
            public void onValidateSuccess() {
                Intent intent = new Intent();
                intent.putExtra("reason", dialogChoiceReason.getText().toString().trim());
                setResult(Activity.RESULT_OK, intent);
                onBackPressed();
            }

            @Override
            public void onValidateError(@NonNull String msg, EditText editText) {
                showShortToast(msg, SnackbarUtil.ALERT);
            }
        });

    }
}
